package com.my.style.adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.my.style.basemodul.R;
import com.sv.jm.baselibrary.utils.GlideHelper;

/**
 * Created by Administrator on 2017/7/9.
 */

public class DesignAdapter extends PagerAdapter {
    Context mConetxt;
    String[] images = {};

    public DesignAdapter(Context mConetxt) {
        this.mConetxt = mConetxt;
    }

    public void setDatas(String[] images) {
        if (images != null) {
            this.images = images;
        }
        notifyDataSetChanged();
    }

    public Object instantiateItem(ViewGroup container, int position) {
        ImageView view = new ImageView(mConetxt);
        GlideHelper.getInstance(mConetxt).loadImage(images[position], view);
        container.addView(view);
        return view;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }

    @Override
    public int getCount() {
        return images.length;
    }

    @Override
    public boolean isViewFromObject(View view, Object o) {
        return view == o;
    }
}
